/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package serversocket;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;

/**
 *
 * @author Leo
 */
public class VerificarConexion implements Runnable{
    private ServerSocket servicio;
    private Socket socketServicio;

    public VerificarConexion(ServerSocket servicio, Socket socketServicio) {
        this.servicio = servicio;
        this.socketServicio = socketServicio;
    }

    public void verificarConexion(ServerSocket servicio, Socket socketServicio) {
        try {
            boolean prueba = true;
            while(prueba) {
                socketServicio = servicio.accept();
                PrintWriter salida = new PrintWriter(socketServicio.getOutputStream(), true);
                BufferedReader entrada = new BufferedReader(new InputStreamReader(socketServicio.getInputStream()));
                
                salida.println("encendido");
                salida.close();
                socketServicio.close();
            }
        } catch (IOException ex) {
            System.out.println("Algo se daño en verificar conexion");
        }
    }
    
    public void run(){
        verificarConexion(servicio, socketServicio);
    }
    
}
